import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login' // Login组件
import Layout from '@/views/Layout' // 首页和我的外框布局
import Home from '@/views/Home'
import My from '@/views/My'
import Search from '@/views/Search'
import SearchResult from '@/views/Search/SearchResult'
import Article from '@/views/Article'
import UserEdit from '@/views/My/UserEdit'
// import Chat from '@/views/Chat/index'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/layout',
    name: 'Layout',
    component: Layout,
    redirect: 'layout/home', // 到layout地址马上显示home页
    children: [
      {
        path: 'home',
        name: 'Home',
        component: Home
      },
      {
        path: 'my',
        name: 'My',
        component: My
      }
    ]
  },
  {
    path: '/search',
    name: 'Search', // 以后改了path页不影响name的跳转方式
    component: Search
  },
  {
    path: '/search_result/:kw', // 动态路由 搜索结果页
    name: 'SearchResult',
    component: SearchResult
  },
  {
    path: '/detail/:a_id', // 文章页
    name: 'Article',
    component: Article
  },
  {
    path: '/my/user', // 路由路径随便写，但是一切都要以当前数组里的规则为准
    name: 'UserEdit',
    component: UserEdit
  },
  {
    path: '/chat', // 聊天页
    name: 'Chat',
    component: () => import('@/views/Chat')
  }
]

const router = new VueRouter({
  routes
})
export default router
